import Admin from "../model/Admin";

class AdminService {
  getAdminById(id: number) {
    return Admin.findOne({
      where: {
        id: id,
      },
    })
  }
  getAdminByName(name: string) {
    return Admin.findOne({
      where: {
        name: name
      }
    })
  }
  addAdmin(admin: any) {
    return Admin.create(admin)
  }
  updateAdmin(id: number, admin: any) {
    return Admin.update(admin, { where: { id: id } })
  }
  deleteAdmin(id: number) {
    return Admin.destroy({where:{id}})
  }
}

export default new AdminService
